]>
Commit | Line | Data |
---|---|---|
1 | IDENTIFICATION DIVISION | |
2 | PROGRAM-ID Damped_Oscillator | |
3 | ||
4 | ENVIRONMENT DIVISION | |
5 | ENGINE Anabrid-THAT | |
6 | REQUIRES COEFFICIENT 5 | |
7 | REQUIRES INTEGRATOR 2 | |
8 | REQUIRES INVERTER 1 | |
9 | REQUIRES SUMMER 2 | |
10 | ||
11 | DATA DIVISION | |
12 | OUTPUT OUTPUT.U y | |
13 | COEFFICIENT.1 InitialPosition | |
14 | COEFFICIENT.2 InitialSpeed | |
15 | COEFFICIENT.3 SpringForce | |
16 | COEFFICIENT.4 Damping # linear to speed | |
17 | COEFFICIENT.5 Mass # 1 / mass | |
18 | ||
19 | PROGRAM DIVISION | |
20 | # Colors being used for wiring | |
21 | # - black: y0 | |
22 | # - blue: y0’ | |
23 | # - green: y0’’ | |
24 | # - yellow: y’’, y’ | |
25 | # - red: y | |
26 | -1 -> COEFFICIENT.InitialPosition -> -y0 # -initial position of the mass | |
27 | -1 -> COEFFICIENT.InitialSpeed -> y0s’ # y’ is scaled to be within -1..+1 | |
28 | +1, y0s’, y0s’ -> SUMMER -> y0’ | |
29 | y’’, IC:y0’ -> INTEGRATOR -> -y’ | |
30 | -y’,IC:-y0 -> INTEGRATOR -> y | |
31 | y -> COEFFICIENT.SpringForce -> S*y # springforce times displacement | |
32 | -y’ -> INVERTER -> y’ | |
33 | y’ -> COEFFICIENT.Damping -> D*y’ # damping times speed | |
34 | S*y, D*y’ -> SUMMER -> -(Dy’+Sy) | |
35 | -(Dy’+Sy) -> COEFFICIENT.Mass -> -1/m*(Dy’+Sy)=y’’ | |
36 | ||
37 | OPERATION DIVISION | |
38 | MODE REPEAT | |
39 | OP-TIME 80ms |